package com.lin.filegraph.utils.filedg;

import com.lin.filegraph.utils.parser.node.JFileNode;

/**
 * @description:
 * @author: linhuaixu
 * @time: 2023/5/18 10:05
 */

public class FileGraphNode {
    private final String fileName;//文件名
    private final String fileType;//文件类型
    private final String relativePath;//相对路径
    private final String absolutePath;//绝对路径
    private final int validLOC;//有效代码行数
    private String packageName;//文件所在包

    public FileGraphNode(String fileName, String fileType, String relativePath, String absolutePath, int validLOC) {
        super();
        this.fileName = fileName;
        this.fileType = fileType;
        this.relativePath = relativePath;
        this.absolutePath = absolutePath;
        this.validLOC = validLOC;
    }

    public FileGraphNode(String fileName, String fileType, String relativePath, String absolutePath, int validLOC, String packageName) {
        super();
        this.fileName = fileName;
        this.fileType = fileType;
        this.relativePath = relativePath;
        this.absolutePath = absolutePath;
        this.validLOC = validLOC;
        this.packageName = packageName;
    }

    public FileGraphNode(String fileName, int validLOC) {
        super();
        this.fileName = fileName;
        this.fileType = null;
        this.relativePath = null;
        this.absolutePath = null;
        this.validLOC = validLOC;
    }

    public FileGraphNode(JFileNode jFile) {
        this(jFile.getFileName(), jFile.getFileType(), jFile.getRelativePath(), jFile.getFilePath(), jFile.getValidLOC(), jFile.getPackage().getPackageName());
    }


    public String getFileName() {
        return fileName;
    }

    public String getFileType() {
        return fileType;
    }

    public String getRelativePath() {
        return relativePath;
    }

    public String getAbsolutePath() {
        return absolutePath;
    }

    public String getPackageName() {
        return packageName;
    }

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }
    //	@Override
//	public String toString() {
//		return fileName+"."+fileType;
//	}

    public int getValidLOC() {
        //有效代码行最小为1
        if (validLOC <= 1) {
            return 1;
        }
        return validLOC;
    }
}

